/*************
Ten tac gia : LY THIEN KIM
Ngay tao : 8/16/2011
Noi dung : update 1 Complaint

*************/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE NAME = 'sp_UpdateComplaint')
BEGIN
	DROP PROC sp_UpdateComplaint
END
GO
CREATE PROC sp_UpdateComplaint
	@ID				int,
	@IDUSER			int,
	@NAME			varchar(40),
	@SEX			smallint,
	@ADDRESS		varchar(100),
	@PHONE			varchar(40),
	@EMAIL			varchar(40),
	@DETAIL			text,
	@DATE			datetime,
	@PLACE			varchar(40),
	@Last_updated	datetime,
	@Result			int out
	AS
	BEGIN	
		IF EXISTS (SELECT * FROM COMPLAINT_REG WHERE ID = @ID and IDUSER = @IDUSER)
		BEGIN
			UPDATE COMPLAINT_REG SET  NAME = @NAME,@SEX = @SEX,ADDRESS = @ADDRESS,PHONE = @PHONE,EMAIL = @EMAIL,DETAIL = @DETAIL,DATE = @DATE,PLACE = @PLACE,Last_updated = @Last_updated
			WHERE ID = @ID and IDUSER = @IDUSER
			SET @Result = 1	
		END
		else
		BEGIN
			SET @Result = 0
		END
	END